package com.qcby.front.controller;


import com.qcby.framwork.utils.ResponseResult;
import com.qcby.front.model.SgComment;
import com.qcby.front.service.SgCommentService;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

/**
 * <p>
 * 评论表 前端控制器
 * </p>
 *
 * @author admin
 * @since 2024-09-20
 */
@RestController
@RequestMapping("/comment")
public class SgCommentController {
    @Autowired
    private SgCommentService sgCommentService;
    //评论列表查询
    @GetMapping("/commentList")
    public ResponseResult getCommentList(Long articleId,Integer pageNum,Integer pageSize){
        //评论类型直接设置为0，代表文章评论
        return sgCommentService.commentList("0",articleId,pageNum,pageSize);
    }
    //发送文章评论
    @PostMapping
    public ResponseResult sendArticleComment(@RequestBody SgComment comment){
        return sgCommentService.addComment(comment);
    }
    //查询友联评论
    @GetMapping("/linkCommentList")
    public ResponseResult getLinkComment(Integer pageNum,Integer pageSize){
        //直接设置评论类型为友联评论，文章id设为null
        return sgCommentService.commentList("1",null,pageNum,pageSize);
    }
}

